// CSE571 - player-game.h
// Authors: Jonathan Wald, Daniel Sarfati, Guangle Fan
// This class holds data for each game that a client-side player connects to.

#ifndef PLAYER_GAME_H
#define PLAYER_GAME_H

#include <vector>
#include <string>
#include <sstream>

#include "ace/Service_Object.h"
#include "ace/SOCK_Stream.h"
#include "ace/Message_Queue_T.h"

#include "player-svc-handler.h"
#include "hand.h"
#include "card.h"

class PlayerGame : public ACE_Service_Object {
 public:
   std::string get_name() { return game_name; }
   std::string get_host() { return host; }
   int get_port() { return port; }
   void send_msg(string message);
   void send_card(Card card);
   PlayerGame();
   ~PlayerGame();
   void discard();
   void sendBackFinal();
   void getPoolCard();
   PlayerSvcHandler handler;
   Hand hand;
   Deck cardPool;
   stringstream stream;
   std::string game_name;
   std::string label;
   bool failed;
   void reset();
   void finish_game();
   bool terminated;
   bool suspended;
   ACE_Reactor_Mask mask;
   ACE_Message_Queue<ACE_NULL_SYNCH> suspension_queue;
   friend class GameManager;
   friend class PlayerSvcHandler;

  // Service methods
   virtual int init (int argc, char *argv[]);
   virtual int fini (void);
   virtual int suspend (void);
   virtual int resume (void);
   virtual int info (char **, size_t = 0);
   
 private:
   std::string dealer_name;
   std::string game_type;
   bool finalHand; 
   int port;
   std::string host;
   int score;
};
template <typename Iterator>
bool next_combination(const Iterator first, Iterator k, const Iterator last);

#endif
